import { Resolver, Query } from '@nestjs/graphql'

@Resolver()
export class DateResolver {
  @Query()
  now() {
    const date = new Date()
    return (
      this.getDix(date.getHours()) +
      ':' +
      this.getDix(date.getMinutes()) +
      ':' +
      this.getDix(date.getSeconds())
    )
  }

  getDix(hours: number): string {
    if (hours < 10) {
      return 0 + '' + hours
    } else {
      return hours + ''
    }
  }
}
